<?php

namespace App\Models\Product;

use Illuminate\Database\Eloquent\Model;
use App\Models\Config as ConfigModel;

class Type extends Model
{

    protected $table = 'product_type';

    public $timestamps = false;

    protected $guarded = [];

    protected $appends = [
        'thumb_text', //产品图
    ];

    public function getThumbTextAttribute()
    {

        $urls = ConfigModel::where('name', 'shourl')->value('value');

        $url = env('SITE_URL', $urls);

        $thumb = !empty($this->attributes['thumb']) ? $url.$this->attributes['thumb'] : $url.'/assets/images/icon_1.png';

        return $thumb;
    }

}